﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.SqlClient;

namespace formworks.DBO.Core
{
    /// <summary>
    /// 一个数据库会话对象接口
    /// </summary>
    public interface IDBSession
    {
        SqlConnection getConn();
        void clearConn();
        SqlCommand getCommand(string sql);

        void restartSession();
        void closeSession();

        void beginTransaction();
        void rollBack();
        void commit();

        SqlDataReader executeQuery(string sql);
        int executeNonQuery(string sql);
        int save<T>(T obj);

        List<T> createQuery<T>(string sql);
        DataSet createQuery(string sql);        

        int insert<T>(T obj);
        int insert<T>(string sql);

        int update<T>(T obj);
        int update<T>(string sql);

        int deleteById<T>(object[] id);
        int delete<T>(string condition);
        int delete<T>(T obj);
    }
}
